<div class="deploy_form">
    <div class="modal-header ">
        <button aria-hidden="true" type="button " class="close close-x" data-dismiss="modal"></button>
        <h3><?php echo $this->language->get('text_create_hd');?></h3>
    </div>
    <div class="modal-body">
        <div  class="form-horizontal" >
            <div class="control-group">
                <label class="control-label"><?php echo $this->language->get('text_hd_name');?><span class="required">*</span></label>
                <div class="controls">
                    <input type="text" name="hd_name" id="hd_name" value="<?php echo $hd_name;?>" class="span6 m-wrap">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><?php echo $this->language->get('text_hd_type');?><span class="required">*</span></label>
                <div class="controls">
                    <select class="span6 m-wrap" name="type" data-placeholder="0">
                    <option value="0" selected="selected"><?php echo $this->language->get('text_hd_performance');?></option>
                    <option value="1"><?php echo $this->language->get('text_hd_extend');?></option>
                    </select>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><?php echo $this->language->get('text_hd_encryption');?><span class="required">*</span></label>
                <div class="controls">
                    <select class="span6 m-wrap" name="encryp_type" id="encryp_type">
                    <option value="0" selected="selected"><?php echo $this->language->get('text_hd_unencryption');?></option>
                    <option value="1"><?php echo $this->language->get('text_hd_encryption');?></option>
                    </select>
                </div>
            </div>
            <div id="input_pin" class="control-group" style="display: none;" disabled="disabled">
                <label class="control-label"><?php echo $this->language->get('text_hd_password');?><span class="required">*</span></label>
                <div class="controls">
                    <input type="text" name="pin" id="pin" value="<?php echo $pin;?>" class="span6 m-wrap">
                </div>
            </div>
            
            
            <div class="control-group">
                <label class="control-label"><?php echo $this->language->get('text_hd_size');?>(GB)<span class="required">*</span></label>
                <div class="controls">
                    <!--
                    <div id="slider-range-max" style="width: 300px"> </div>
                    <input type="hidden" id="slider"value="10" class="span6 m-wrap" > 
                    -->
                    <input type="text" name="size" id="size" value="<?php echo $size;?>"  class="span6 m-wrap">GB 
                    <label><i>(10-500G <?php echo $this->language->get('text_hd_multiple_ten');?>)</i></label>
                </div>
                
            </div>
            <input name="app_id" type="hidden" value="<?php echo $app_id;?>">
            <input name="region" type="hidden" value="<?php echo $region;?>">
            <div class="modal-footer ">
                <button aria-hidden="true" type="button " class="btn close" data-dismiss="modal"><?php echo $this->language->get('text_hd_cancel');?></button>
                <?php if(isset($edit)){ ?>
                <button aria-hidden="true" id="hd_edit_submit_btn" class="btn green btn-primary " type="button" value="<?php echo $app_id;?>"><i class="icon-ok"></i><?php echo $this->language->get('text_hd_modify');?></button>
                <?php }else{ ?>
                <button aria-hidden="true" id="hd_submit_btn" class="btn green btn-primary " type="button" value="<?php echo $app_id;?>"><i class="icon-ok"></i><?php echo $this->language->get('text_hd_confirm');?></button>
                <?php } ?>
            </div>
       </div>
    </div>
</div>


<script>

    $(document).keyup(function(event){
        if(event.keyCode ==13){
            $("#hd_submit_btn").trigger("click");
            $("#hd_edit_submit_btn").trigger("click");
        }
    });
    $(function(){
    	//slider
    	/*
	      $("#slider-range-max").slider({
	      range: "min",
	      min: 10,
	      max: 500,
	      value: 10,
	      slide: function( event, ui ) {
	        $("input[name='size']").val(ui.value);
	      }
	    });
	    $("input[name='size']").val( $("#slider-range-max" ).slider( "value" ));
	    */
        //end
        
        $("#encryp_type").change(function(){
        	if( $("#encryp_type").val() == 1){
        		$("#input_pin").show();
        	}
        	else{
        		$("#input_pin").hide();
        	}
        	
        })
        
        //check hd name exites
        $("input[name='hd_name']").change(function(){
            var ef=$(this);
            $.ajax({
                url: 'index.php?route=deploy/hd/check_hd_name_exist',
                cache: false,
                dataType: 'json',
                type: 'POST',
                data: {
                    hdname: $(this).val(),
                    region: '<?php echo $region;?>',
                    app_id: $('input[name=\'app_id\']').val()
                },
                error: function() {
                },
                beforeSend: function() {
                    ef.after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
                },
                complete: function() {
                    $('.wait').remove();
                },
                success: function(json) {
                    if(json['result']=='success'){
                        ef.removeClass();
                        ef.addClass("success");
                    }else{
                        ef.removeClass();
                        ef.addClass("error");
                    }
                }
            });
        });
        
    })
</script>